var textFontSize = 100;
//Debug
console = new Object();
console.log = function(log) {
    var iframe = document.createElement("iframe");
    iframe.setAttribute("src", "ios-log:#iOS#" + log);
    document.documentElement.appendChild(iframe);
    iframe.parentNode.removeChild(iframe);
    iframe = null;    
}
function zoom(scale){
	if (scale<1)
		textFontSize = (textFontSize > 60) ? textFontSize-10 : textFontSize;
	else if (scale>1 && scale<10)
		textFontSize = (textFontSize <200) ? textFontSize+10 : textFontSize;
    else if (scale = 10)
        textFontSize = 120;
    else if (scale = 20)
        textFontSize = 140;
	else
		textFontSize = 100;
	$('body').css('webkitTextSizeAdjust',textFontSize+'%');
}
/*
$(function(){
	$('#body').die();
	$('#body').live('gestureend',function(e){
        console.log('gestureend');
		e.preventDefault();
		if (e.originalEvent.scale<1) {
			textFontSize = (textFontSize > 80) ? textFontSize-10 : textFontSize;
		} else {
			textFontSize = (textFontSize <180) ? textFontSize+10 : textFontSize;
		}
		$('body').css('webkitTextSizeAdjust',textFontSize+'%');
	});
    
	$('#body').doubletap(
	    function(event){
	    	textFontSize = 100;
	        $('body').css('webkitTextSizeAdjust',textFontSize+'%');
            console.log('doubletap');
	    },
	    null,
	    400
	);
    
});

(function($){
	// Determine if we on iPhone or iPad
 
	$.fn.doubletap = function(onDoubleTapCallback, onTapCallback, delay){
		var eventName, action;
		delay = delay == null? 500 : delay;
		eventName = 'touchend';
 
		$(this).bind(eventName, function(event){
			var now = new Date().getTime();
			var lastTouch = $(this).data('lastTouch') || now + 1; // the first time this will make delta a negative number
			var delta = now - lastTouch;
			clearTimeout(action);
			if(delta<500 && delta>0){
				if(onDoubleTapCallback != null && typeof onDoubleTapCallback == 'function'){
					onDoubleTapCallback(event);
				}
			}else{
				$(this).data('lastTouch', now);
				action = setTimeout(function(evt){
					if(onTapCallback != null && typeof onTapCallback == 'function'){
						onTapCallback(evt);
					}
					clearTimeout(action);   // clear the timeout
				}, delay, [event]);
			}
			$(this).data('lastTouch', now);
			console.log(event.clientX +'-'+event.clientY+''+event.offsetX+'-'+event.offsetY+'-'+event.pageX+'-'+event.pageY);
		});
	};
})(jQuery);
*/